/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2025-11-17
 * Time: 11:35
 */
public class DesTest {
    // 测试
    public static void main(String[] args) {
        DES des = new DES();
        String plaintext = "this is a test";
        String desKey = "12345678"; // 8字节密钥

        // DES测试
        String desCipher = des.encryptString(plaintext, desKey);
        String desDecrypted = des.decryptString(desCipher, desKey);
        System.out.println("=== DES测试 ===");
        System.out.println("明文: " + plaintext);
        System.out.println("密文: " + desCipher);
        System.out.println("解密后: " + desDecrypted);
        System.out.println("验证: " + plaintext.equals(desDecrypted));

        // 三重DES测试
        String key1 = "key12345";
        String key2 = "key67890";
        String key3 = "keyabcde";
        String tripleCipher = des.tripleEncryptString(plaintext, key1, key2, key3);
        String tripleDecrypted = des.tripleDecryptString(tripleCipher, key1, key2, key3);
        System.out.println("\n=== 三重DES测试 ===");
        System.out.println("明文: " + plaintext);
        System.out.println("密文: " + tripleCipher);
        System.out.println("解密后: " + tripleDecrypted);
        System.out.println("验证: " + plaintext.equals(tripleDecrypted));
    }
}
